package com.zcx.test.service.impl;

import com.zcx.test.mapper.MenuMapper;
import com.zcx.test.pojo.Menu;
import com.zcx.test.pojo.User;
import com.zcx.test.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhaochangxin
 * @date 2022/3/4 10:30
 */
@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    MenuMapper menuMapper;

    @Override
    public Menu queryMenuById(Integer id) {
        return menuMapper.selectByPrimaryKey(Long.valueOf(id));
    }

    @Override
    public List<Menu> queryRootMenu() {
        return menuMapper.queryRootMenu();
    }

    @Override
    public List<Menu> queryMenuByParentId(String parentId) {
        return menuMapper.queryMenuByParentId(parentId);
    }

    @Override
    public void insertMenu(Menu menu) {
        menuMapper.insertMenu(menu);
    }

    /**
    　* @author zhaochangxin
    　* @Description:通过Id删除菜单包括其下所有的子目录
    　* @Param id:
    　* @return: void
    　* @date 2022/3/10 10:35
    　* @throws
    　*/
    @Override
    public void deleteMenuById(String id) {
        menuMapper.deleteMenuById(id);
    }

    @Override
    public List<User> queryUserByMenuId(String id) {
        return menuMapper.queryUserByMenuId(id);
    }

}
